<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>TagRequest</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</head>
<body>
    <div id="app">
        <button @click="addTag">addTag</button>
        <button @click="deleteTag">deleteTag</button>
        <button @click="updateTag">updateTag</button>
        <button @click="getInfosByTag">getInfosByTag</button>
        <button @click="getTagById">getTagById</button>
    </div>
<script>
    const send=(req)=>{
        axios({
            method:"post",
            url:"http://localhost:80/tag",
            data:req
        }).then(function (resp) {
            console.log(resp.data)
        })
    }
    var vm=new Vue({
        el: '#app',
        methods: {
            addTag(){
                let tag={
                    name:"",
                    details:""
                };
                let req={
                    type:"req_addTag",
                    value:tag
                }
                send(req);
            },
            deleteTag(){
                let req={
                    type:"req_deleteTag",
                    value:"id"
                }
                send(req);
            },
            updateTag(){
                /*在addTag报文的基础上，tag多了id*/
                let tag={
                    id:"",
                    name:"",
                    details:""
                };
                let req={
                    type:"req_updateTag",
                    value:tag
                }
                send(req);
            },
            //获取标签的所有信息
            getInfosByTag(){
                let req={
                    type:"req_getInfosByTag",
                    value:"id"
                }
                send(req);
                let resp={
                    type:"resp_getInfosByTag",
                    isSuccess:true,
                    value:[]
                }
            },
            getTagById(){
                let req={
                    type:"req_getTagById",
                    value:["id1","id2","id3"]
                }
                send(req);
                let tag={
                    id:"",
                    name:"",
                    details:""
                };
                let resp={
                    type:"resp_getTagById",
                    isSuccess:true,
                    value:[tag,tag,tag]
                }
            },
        }
    })
</script>
</body>
</html>